using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;

namespace Slf.Samples.CompositeLoggerSample
{
  class Program
  {
    static void Main(string[] args)
    {
      Console.ForegroundColor = ConsoleColor.Green;
      Console.WriteLine("This sample logs to different loggers. Run in Debug Mode to see all output.\n");
      Console.ResetColor();


      //create a ConsoleLogger, a DelegateLogger, and a TraceLogger
      ILogger consoleLogger = new ConsoleLogger();
      ILogger delegateLogger = new DelegateLogger(li => Console.WriteLine("Delegate Logger: " + li.Message));
      ILogger traceLogger = new TraceLogger();

      //create the CompositeLogger - you can submit as many loggers as you want through the constructor
      CompositeLogger compositeLogger = new CompositeLogger(consoleLogger, delegateLogger, traceLogger);
      LoggerService.SetLogger(compositeLogger);

      //assign another logger after construction through the "Loggers" list
      compositeLogger.Loggers.Add(new DelegateLogger(li => Debug.WriteLine("2nd Delegate Logger: " + li.Message)));
      
      DoSomeWork();
      Console.ReadLine();
    }

    private static void DoSomeWork()
    {
      ILogger logger = LoggerService.GetLogger();
      logger.Info("hello world");
    }
  }
}